package cn.itcast.zt.java8.reflect;

import cn.hutool.json.JSONUtil;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * create by zhangtian105 on 2021/3/26
 */
public class Parent<T> {
    //用于记录value更新的次数，模拟日志记录的逻辑
    AtomicInteger updateCount = new AtomicInteger();
    private T value;

    public void setValue(T t) {
        this.value = value;
        updateCount.incrementAndGet();
    }

    //重写toString，输出值和值更新次数
    @Override
    public String toString() {
        return String.format("value: %s updateCount: %d", value, updateCount.get());
    }
}
